Skip to content

Delete unused refs from the tuple argument entirely#221

Merged
penelopeysm merged 2 commits intomainfrom
py/perf2
Mar 27, 2026
Merged

Delete unused refs from the tuple argument entirely#221
penelopeysm merged 2 commits intomainfrom
py/perf2

Conversation

@penelopeysm
Copy link
Copy Markdown
Member

@penelopeysm penelopeysm commented Mar 25, 2026

Followup to #220. That PR optimises Libtask such that unnecessary calls to get_ref_at / set_ref_at! are excised from the IR. However, the unused Refs themselves are still kept around in the tuple that is passed as the first argument to the OpaqueClosure. This PR gets rid of them, essentially by renumbering any refs that survive from 1 to N and transforming the IR appropriately.

Running the benchmarks on the TapedTasks in src/benchmarks reveal some nice improvements:

Rosenbrock

main: 2.134 ms (687 allocs: 6.272 MiB)
this PR: 2.017 ms (291 allocs: 6.259 MiB)

Ackley

main: 24.955 ms (699582 allocs: 18.306 MiB)
this PR: 22.578 ms (699528 allocs: 18.304 MiB)

matrix_test

main: 272.083 μs (503 allocs: 593.438 KiB)
this PR: 218.250 μs (214 allocs: 583.453 KiB)

neural_net

main: 3.046 μs (54 allocs: 2.172 KiB)
this PR: 2.638 μs (35 allocs: 1.672 KiB)

@github-actions
Copy link
Copy Markdown

Libtask.jl documentation for PR #221 is available at:
https://TuringLang.github.io/Libtask.jl/previews/PR221/

@penelopeysm penelopeysm marked this pull request as ready for review March 27, 2026 23:17
@penelopeysm penelopeysm changed the title First pass at deleting refs from the tuple entirely Delete unused refs from the tuple argument entirely Mar 27, 2026
@penelopeysm penelopeysm merged commit 98e8a45 into main Mar 27, 2026
22 checks passed
@penelopeysm penelopeysm deleted the py/perf2 branch March 27, 2026 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant